var App = {
	Path:'',
	Group: {
        cid : 15,
		name :'乒乓球'
	},
	pid:12,
	getGroup:function(pid){
		var group = new Object();
		if(pid=='12'){
			group.cid   = 15;
			group.name  = "兵乓球";
		}else if(pid=='13'){
			group.cid   = 20;
			group.name  = "足球";
		}else  if(pid=='18'){
			group.cid   = 22;
			group.name  = "体操";
		}
		return group;
	},
	//对象转Json
    getObjJson: function (aObj) {
        var ajson = null;
        try {
            ajson = JSON.stringify(aObj);
        }
        catch (cer) { ; }
        return ajson;
    },
	OnclickHandle: function (path,id) { 
		App.Path = path;
		if(id){
			App.pid = id;
		}
        try {
        	//返回顶部
    		$(window).scroll(function() {
    			if ($(window).scrollTop() >= 200) {
    				$(".gototop").fadeIn(300);
    			} else {
    				$(".gototop").fadeOut(300);
    			}
    		})
    		$(".gototop").click(function() {
    			$('html,body').animate({
    				'scrollTop' : '0px'
    			}, 300);
    		})
    		//点击切换标签
            $(".nav-tabs li").on("click", function () {
                var index = $(this).index();
                if(index == 0){
                	App.ShowindexInfo();
                }else if(index == 1){
                	App.ShowSingleDateInfo();
                }else if(index == 2){
                	App.ShowSingleSportInfo();
                }else if(index == 3){
                	App.ShowRecordInfo();
                }else if(index == 4){
					App.showReportInfo();
				}
            });
        } catch (cer) {; }
	},
	//控制面板展开和收起
	upDown:function(fullDate){
		var ele = $("#slideDiv"+fullDate);
		if(ele.data("state") == "show"){
			ele.data("state","hide");
			ele.html("<i class='toggle-txt'>展开</i><i class='fa fa-arrow-circle-down'></i>");
		}else{
			ele.data("state","show");
			ele.html("<i class='toggle-txt'>收起</i><i class='fa fa-arrow-circle-up'></i>");
		}
		/*点击面板内容收缩或展开*/
		$(".slide-toggle-"+fullDate).slideToggle(50);
	},
	//点击跳转总日程页面
	ShowindexInfo: function () {
		try {
			if(App.pid=='12'){
				window.location.href = App.Path;
			}else if(App.pid=='13'){
				window.location.href = App.Path+'qzty';
			}else if(App.pid=='18'){
				window.location.href = App.Path+'shjlb';
			}
		} catch (cer) {; }
	},	
	//点击跳转决赛成绩页面
    ShowSingleDateInfo: function (day) {
        try {
        	var params =  "pid="+App.pid;
        	if(day){
        		params+="&day="+day;
        	}
        	params = base64encode(encodeURI(params));
            window.location.href = App.Path+"dateInfo?"+params;        
        } catch (cer) {; }
    },	
    //点击跳转单项成绩页面
	ShowSingleSportInfo: function (cid,name,day,typeName) {
		if(typeName==null){
			if(App.pid==12){
				typeName='体校组'

			}else if(App.pid==13){
				typeName='普通群众'
			}else{
				typeName=' '
			}
		}
		var group = App.getGroup(App.pid);
		if(cid){
			group.cid   = cid;
			group.name  = name;
		}
		var params = "groupStr="+App.getObjJson(group)+"&pid="+App.pid+'&typeName='+typeName;
		if(day){
			params+="&day="+day;
		}
		params = base64encode(encodeURI(params));
		window.location.href = App.Path+"sportInfo?"+params;
	},
	//查看运动员详情
    ShowAthleteBaseInfo: function (cid) {
    	var w = window.open();
    	w.location = App.Path+'athleteBaseInfo?' +base64encode(encodeURI('cid='+cid ));
    },
    //点击跳转纪录页面
    ShowRecordInfo: function (type) {
    	var param ;
    	if(type== undefined || !type ){
    		param = '0';  //默认按照项目进行分组 按照时间分组就是1
    	}else{
    		param = type;
    	}
    	window.location.href = App.Path+'recordInfo/'+param+'?'+base64encode(encodeURI('pid='+App.pid ));

    },
	//跳转到奖牌榜
	showReportInfo:function(){
		window.location.href = App.Path + 'reportInfo/' + 0 + '?'+base64encode(encodeURI('pid='+App.pid ));
	},
	 
	tabClick:function(tab){
		var text = tab.context.innerText
		var type = 0
		if(text == "体校组"){
			type = 1
		}else if(text == "中学生组"){
			type = 2
		}else if(text == "大学生组"){
			type = 3
		}else if(text == "普通群众"){
			type = 1
		}else if(text == "少数民族"){
			type = 2
		}else if(text == "农民"){
			type = 3
		}else if(text == "残疾人"){
			type = 4
		}else{
			type = 0
		}
		window.location.href = App.Path + 'reportInfo/' + type + '?'+base64encode(encodeURI('pid='+App.pid ));

	} ,
	 
	ShowReportDetail:function(uname,uid,type){
		var w = window.open();
		w.location = App.Path + 'reportInfo/detail/' + type + '?'+base64encode(encodeURI('uid='+uid +'&uname='+ uname+'&pid='+App.pid));
	}
}



